﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CreatePGSQLDataScript
{
    public partial class excelColor : Form
    {
        public excelColor()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            object[,] data = new object[100, 1];
            Type t= System.Type.GetType("System.Data.CommandType");


            foreach (System.Reflection.FieldInfo finfo in t.GetFields())
            {
                listBox1.Items.Add(finfo.Name);
            }
            


        }




        ////輸出EXCEL
        //public void TableToExcel(object[,] dataArray, string ExcelName, int width)
        //{


        //    object miss = Missing.Value;
        //    Excel.Application excelApp = new Excel.Application();                                           //开打Excel
        //    excelApp.Workbooks.Add(miss);

        //    try
        //    {
        //        Excel.Worksheet workSheet = (Excel.Worksheet)excelApp.Worksheets[1];                        //创建工作表单
        //        excelApp.DisplayAlerts = false;

        //        workSheet.Cells.Select();                                                                   //全表自动列宽
        //        workSheet.Cells.Columns.AutoFit();

        //        Excel.Range myrange = workSheet.get_Range(workSheet.Cells[1, 1], workSheet.Cells[dataArray.Length / width, width]);      //取数组所在位置
        //        myrange.NumberFormat = "@";                                                                                  //设置文本格式
        //        Excel.Workbook workBook = excelApp.Workbooks[1];
        //        workSheet.get_Range(workSheet.Cells[1, 1], workSheet.Cells[dataArray.Length / width, width]).Value2 = dataArray;//把数组添加到工作表单上

        //        int iCount = colorLines.Count + colorSameLines.Count + colorFullSameLines.Count;

        //        progressBar1.Value = 0;
        //        progressBar1.Maximum = iCount;
        //        lbSum.Text = iCount.ToString();

        //        lblCurrOpt.Text = "正在設置顏色。。。";

        //        int iindex = 0;

        //        //顏色
        //        foreach (int i in colorLines)
        //        {
        //            //workSheet.get_Range(workSheet.Cells[i + 1, 1], workSheet.Cells[i + 1, 5]).Font.Color = System.Drawing.Color.FromArgb(Color.SkyBlue.B,Color.SkyBlue.G,Color.SkyBlue.R).ToArgb(); ;// "#783114";
        //            workSheet.get_Range(workSheet.Cells[i + 1, 1], workSheet.Cells[i + 1, 6]).Font.Color = System.Drawing.Color.OrangeRed.ToArgb();

        //            if (i % 100 == 0)
        //            {
        //                progressBar1.Value = iindex;
        //                lbCu.Text = iindex.ToString();
        //                Application.DoEvents();
        //            }
        //            iindex++;
        //        }


        //        progressBar1.Value = iindex;
        //        lbCu.Text = iindex.ToString();
        //        Application.DoEvents();

        //        lblCurrOpt.Text = "寫入Excel。。。";


        //        ////加粗
        //        //foreach (int i in BlodLines)
        //        //{
        //        //    workSheet.get_Range(workSheet.Cells[i + 1, 1], workSheet.Cells[i + 1, 6]).Font.Bold = "true";
        //        //}

        //        workBook.SaveAs(ExcelName, miss, miss, miss, miss, miss, Excel.XlSaveAsAccessMode.xlExclusive, miss, miss, miss, miss, miss);     //保存文件
        //        workBook.Close(false, miss, miss);
        //        workBook = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }
        //    finally
        //    {
        //        excelApp.Quit();
        //        excelApp = null;
        //        GC.Collect();
        //        //KillExcelProcess();//结束excel进程       
        //    }
        //}
   
    
    
    }
}
